<?php
/**
 * Created by PhpStorm.
 * User: tt
 * Date: 2018/1/13
 * Time: 13:46
 */

namespace app\admin\model;

use think\Cache;
use think\Model;

class Origin extends Model
{
    //put your code here
    public function getStatusTextAttr($value,$data)
    {
        $status = [1=>'<span class="label label-success">正常</span>',0=>'<span class="label label-danger">禁用</span>'];
        return $status[$data['status']];
    }

    /**
     * 获取所有的来源
     * @return array|mixed
     * @author: Huang
     */
    public function getAllOrigin(){
        $data = Cache::tag('Origin')->get('Origindata');
        if(!$data){
//            dump($data=$this->column('name','id'));
//            die();
            $data=$this->column('name','id');
            Cache::tag('Origin')->set('Origindata',$data);
        }
        return $data;
    }
}